package service

import (
	"mxshop/app/mxshop_api/api/internal/data"
	srvGoods "mxshop/app/mxshop_api/api/internal/service/goods"
	serviceGoods "mxshop/app/mxshop_api/api/internal/service/goods/v2"
	srvInv "mxshop/app/mxshop_api/api/internal/service/inv"
	serviceInv "mxshop/app/mxshop_api/api/internal/service/inv/v1"
	srvSms "mxshop/app/mxshop_api/api/internal/service/sms"
	serviceSms "mxshop/app/mxshop_api/api/internal/service/sms/v1"
	srvUser "mxshop/app/mxshop_api/api/internal/service/user"
	serviceUser "mxshop/app/mxshop_api/api/internal/service/user/v1"
	"mxshop/pkg/options"
)

type ServiceFactory interface {
	Goods() srvGoods.GoodsFactory
	User() srvUser.UserFactory
	Sms() srvSms.SmsFactory
	Inv() srvInv.InvFactory
}

type service struct {
	data    data.DataFactory
	smsOpts *options.SmsOptions
	jwtOpts *options.JwtOptions
}

func (s *service) Sms() srvSms.SmsFactory {
	return serviceSms.NewService(s.smsOpts)
}

func (s *service) Goods() srvGoods.GoodsFactory {
	return serviceGoods.NewService(s.data)
}

func (s *service) User() srvUser.UserFactory {
	return serviceUser.NewService(s.data, s.jwtOpts)
}

func (s *service) Inv() srvInv.InvFactory {
	return serviceInv.NewService(s.data)
}

func NewService(data data.DataFactory, smsOpts *options.SmsOptions, jwtOpts *options.JwtOptions) ServiceFactory {
	return &service{data: data,
		smsOpts: smsOpts,
		jwtOpts: jwtOpts,
	}
}
